Ext.ns("examQualification");
examQualification.init = function() {
	examQualification.big_Id;// 定义选定的大类型的序列号
	examQualification.big_Name;// 定义选定的大类型名称
	examQualification.small_Id;// 定义选定的小类型的序列号
	examQualification.small_Name;// 定义选定的大类型名称
	examQualification.exam_Id;
	examQualification.exam_Name;
	examQualification.photo_Name;
	examQualification.startTime;
	examQualification.endTime;
	examQualification.photoPath;
	examQualification.MenuClick;
	examQualification.Menu;
	examQualification.cm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(), {
				header : '考试名称',
				dataIndex : 'examInfo_Name',
				sortable : true
			}, {
				header : '考试类型',
				dataIndex : 'examInfo_Type.small_Name',
				sortable : true
			}, {
				header : '考试费用(单价：元)',
				dataIndex : 'examInfo_Money',
				sortable : true
			}, {
				header : '考试开场时间',
				dataIndex : 'examInfo_StartTime',
				renderer : Ext.util.Format.dateRenderer('Y年m月d日   h时i分'),
				sortable : true
			}, {
				header : '考试创建时间',
				dataIndex : 'examInfo_CreateTime',
				renderer : Ext.util.Format.dateRenderer('Y年m月d日'),
				sortable : true
			}, {
				header : '考试说明',
				dataIndex : 'examInfo_Comments',
				sortable : true
			}]);

	examQualification.store = new Ext.data.JsonStore({
				url : 'center/showexamValue',
				totalProperty : 'total',
				root : 'examValues',
				fields : [{
							name : "examInfo_Name",
							mapping : 'examInfo_Name',
							type : 'string'
						}, {
							name : "examInfo_Id",
							mapping : 'examInfo_Id',
							type : 'string'
						}, {
							name : "examInfo_Type.small_Name",
							mapping : 'examInfo_Type.small_Name',
							type : 'string'
						}, {
							name : "examInfo_Type.small_Id",
							mapping : 'examInfo_Type.small_Id',
							type : 'int'
						}, {
							name : "examInfo_Money",
							mapping : 'examInfo_Money',
							type : 'float'
						}, {
							name : "examInfo_StartTime",
							mapping : 'examInfo_StartTime',
							type : 'string'
						}, {
							name : "examInfo_EndTime",
							mapping : 'examInfo_EndTime',
							type : 'string'
						}, {
							name : "examInfo_CreateTime",
							mapping : 'examInfo_CreateTime',
							type : 'string'
						}, {
							name : "examInfo_Comments",
							mapping : 'examInfo_Comments',
							type : 'string'
						}, {
							name : "examInfo_Photo.photo_Name",
							mapping : 'examInfo_Photo.photo_Name',
							type : 'string'
						}]
			});
	examQualification.BigTypes = new Ext.data.JsonStore({
				url : 'conduction/showBigList',
				totalProperty : 'total',
				root : 'bigs',
				fields : [{
							name : "big_Id",
							type : 'int'
						}, {
							name : "big_Name",
							type : 'string'
						}]
			});
	examQualification.SmallTypes = new Ext.data.JsonStore({
				url : 'conduction/showSmallList',
				totalProperty : 'total',
				root : 'smalltypes',
				fields : [{
							name : "small_Id",
							mapping : 'small_Id',
							type : 'int'
						}, {
							name : "small_Name",
							mapping : 'small_Name',
							type : 'string'
						}, {
							name : "small_Date",
							mapping : 'small_Date',
							type : 'date'
						}, {
							name : "small_State",
							mapping : 'small_State',
							type : 'string'
						}]
			});
	examQualification.Panel = new Ext.grid.GridPanel({
				deferredRender : true,
				cm : examQualification.cm,
				store : examQualification.store,
				loadMask : true,
				height : 450,
				viewConfig : {
					columnsText : '选择显示列',
					forceFit : true
				},
				tbar : new Ext.Toolbar(['-', {
							id : 'examQualification_search_bigType',
							fieldLabel : '考试类型',
							allowBlank : false,
							emptyText : '请选择考试类型进行查询',
							blankText : '对不起，请选择考试类型',
							xtype : 'combo',
							mode : 'remote',
							triggerAction : 'all',
							valueField : 'big_Id',
							displayField : 'big_Name',
							pageSize : 8,
							minListWidth : 300,
							store : examQualification.BigTypes
						}, '-', {
							id : 'examQualification_search_smallType',
							fieldLabel : '考试类型细节',
							allowBlank : false,
							emptyText : '请选择类型细节',
							blankText : '对不起，请选择类型细节进行查询',
							name : 'examValue.exam_Type',
							xtype : 'combo',
							mode : 'local',
							triggerAction : 'all',
							valueField : 'small_Id',
							displayField : 'small_Name',
							pageSize : 8,
							minListWidth : 300,
							store : examQualification.SmallTypes
						}, "-", {
							text : "查询最新发布考试信息",
							handler : function() {
								examQualification.store.load({
											params : {
												state: 1,//查找最新的发布信息
												start : 0,
												limit : 12
											}
										});
							}
						}]),
				bbar : new Ext.PagingToolbar({
							id : 'examQualification.pagetool',
							pageSize : 10,
							store : examQualification.store,
							displayInfo : true,
							displayMsg : '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
							emptyMsg : "没有记录"
						})
			});
	examQualification.Menu = new Ext.menu.Menu({
		id : 'examQualification_Menu',
		items : [{
			text : "查看详情",
			handler : function() {
					examQualification.photoPath = "dateFile/examInfo/"
						+ new String(examQualification.MenuClick
										.get("examInfo_Type.small_Id"))
						+ "/"
						+ new String(examQualification.MenuClick
										.get("examInfo_Photo.photo_Name"));
				examQualification.showPanel = new Ext.FormPanel({
							defaultType : 'displayfield',
							width : 700,
							labelAlign : 'center',
							constrain : true,
							constrainHeader : true,
							bodyStyle : {
								padding : '30px'
							},
							viewConfig : {
								forceFit : true
							},
							items : [{
								fieldLabel : '考试名称',
								value : examQualification.MenuClick
										.get("examInfo_Name")
							}, {
								fieldLabel : '考试类型',
								value : examQualification.MenuClick
										.get("examInfo_Type.small_Name")
							}, {
								fieldLabel : '考试费用',
								value : examQualification.MenuClick
										.get("examInfo_Money")
							}, {
								fieldLabel : '考试开场时间',
								value : examQualification.MenuClick.get("examInfo_StartTime")
							}, {
								fieldLabel : '考试结束时间',
								value : examQualification.MenuClick
										.get("examInfo_EndTime")
							},{
								inputType : 'image',
								autoCreate : {
									tag : "input",
									type : "image",
									src : examQualification.photoPath
								},
								width : 200,
								height :100,
								fieldLabel : '照片'
							},{
								fieldLabel : '考试说明',
								value : examQualification.MenuClick
										.get("examInfo_Comments")
							}],
							buttonAlign : 'center',
							buttons : [{
										text : '退出',
										handler : function() {
											examQualification.showWindow.close();
										}

									}]
						});

				examQualification.showWindow = new Ext.Window({
							title : '考试信息详细信息窗口',
							width : 700,
							autoHeight : true,
							modal : true,
							resizable : false,
							animateTarget : 'target',
							items : [examQualification.showPanel]
						});
				examQualification.showWindow.show();
			}
		}, {
			text : '申请考场资格',
			handler : function() {
				Ext.Ajax.request({
							url : 'conduction/applyForQualification',
							method : 'post',
							params : {
								exam_Id : examQualification.MenuClick
										.get("examInfo_Id"),
								state : 1
							},
							success : function(response) {
								var obj = Ext.decode(response.responseText);
								if (obj.success == false) {
									Ext.Msg.alert("提示", obj.msg);
								} else {
									Ext.Msg.alert("提示", obj.msg);
								}
							},
							failure : function(response) {

							}
						});
			}
		}]
	});
	examQualification.Main = new Ext.Panel({
				title : '资格申请窗口',
				id : 'applyExamQualification',
				frame : true,
				deferredRender : true,
				closeAction : 'hide',
				cm : examQualification.cm,
				store : examQualification.store,
				loadMask : true,
				autoWidth : true,
				closable : true,
				layout : 'fit',
				viewConfig : {
					forceFit : true
				},
				items : [examQualification.Panel]
			});
	Ext.getCmp("examQualification_search_bigType").on('select', function(combo) {
		examQualification.SmallTypes.load({
					params : {
						big_Id :combo.getValue(),
						start : 0,
						limit : 12
					}
				});
	});
	Ext.getCmp("examQualification_search_smallType").on('select', function(combo) {
		examQualification.store.load({
					params : {
						small_Id :combo.getValue(),
						start : 0,
						limit : 12
					}
				});
	});
	examQualification.Panel.on("rowcontextmenu", function(grid, rowIndex, e) {
				e.preventDefault();
				examQualification.Panel.getSelectionModel().selectRow(rowIndex);
				examQualification.Menu.showAt(e.getXY());
				examQualification.MenuClick = examQualification.Panel
						.getSelectionModel().getSelected(rowIndex);
			});
};
Ext.onReady(examQualification.init);